var categoryCmsObject = new Ext.Vnf.CategoryTree(null, true, true, {
            dataUrl         : '<?=BASE_URL?>/category/get-tree',

            containerScroll : true,
            listeners       : {
                'beforemovenode' : function(tree, node, oldParent, newParent,
                        newIdx) {

                    // only get newParent if node has change parent
                    var newPID = (oldParent.id != newParent.id) ? newParent.id : -1;
                    var oldChildNodes = oldParent.childNodes;
                    var newChildNodes = newParent.childNodes;
                    var currIdx = oldChildNodes.indexOf(node);
                    var role = 'under';
                    var relateNode = null;
                    var order = true;
                    var url = '';

                    if (oldParent.id == newParent.id) {
                        if (currIdx < newIdx) {
                            if (currIdx + 1 == newIdx) {
                                return false;
                            }
                            relateNode = oldChildNodes[newIdx - 1];
                        } else {
                            role = 'upper';
                            relateNode = oldChildNodes[newIdx];
                        }
                    } else {
                        if (newChildNodes.length != 0) {
                            if (newIdx < newChildNodes.length)
                                relateNode = newChildNodes[newIdx];
                            else {
                                order = false;
                                relateNode = newChildNodes[newIdx - 1];
                            }
                        } else {
                            order = false;
                        }
                    }

                    if (relateNode != null) {
                        url = '<?=BASE_URL?>/category/reorder/cid/'
                                + node.id + '/rid/' + relateNode.id + '/pid/'
                                + newPID + '/ord/' + order;
                    } else {
                        url = '<?=BASE_URL?>/category/reorder/cid/'
                                + node.id + '/pid/' + newPID + '/ord/' + order;
                    }
                    var flag = false;
                    //vns.startMask();
                    Ext.Ajax.request({
                                url     : url,
                                success : function(responseObject) {
                                    if (responseObject.responseText != "true") {
                                        // an error on order tree
                                        // reload tree
                                        tree.root.reload();
                                        tree.expandAll();
                                        Ext.Msg
                                                .alert('Status',
                                                        "Can't order this node")
                                    }
                                    //vns.endMask();
                                    flag = true;
                                },
                                failure : function() {
                                    // reload tree
                                    tree.root.reload();
                                    tree.expandAll();
                                    Ext.Msg.alert('Status',
                                            "Can't order this node")
                                    //vns.endMask();
                                }
                            });
                }
            }
        });

var getCategoryCmsWindow = new Ext.Window({
    id              : 'get-category-multi-level-cms',
    title           : 'get-category-multi-level-cms',
    width           : 400,
    height          : 400,
    iconCls         : 'icon-grid',
    shim            : false,
    animCollapse    : false,
    constrainHeader : true,
    layout          : 'fit',
    modal           : true,
    closable        : true,
    items           : [categoryCmsObject],
    containerScroll : true
});

getCategoryCmsWindow.show();
categoryCmsObject.expandAll();